load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "compression",
    srcs = [
        "Compression.cpp",
        "Zlib.cpp",
        "Zstd.cpp",
    ],
    hdrs = [
        "Compression.h",
        "Utils.h",
        "Zlib.h",
        "Zstd.h",
    ],
    local_defines = [
        # NOTE: This is defined in lz4_hc/lz4hc.h
        # "LZ4_STATIC_LINKING_ONLY",
        "LZ4_HC_STATIC_LINKING_ONLY",
        "LZ4F_STATIC_LINKING_ONLY",
    ],
    deps = [
        ":compression_context_pool_singletons",
        "//folly:conv",
        "//folly:memory",
        "//folly:optional",
        "//folly:portability",
        "//folly:random",
        "//folly:range",
        "//folly:scope_guard",
        "//folly:stop_watch",
        "//folly:varint",
        "//folly/io:iobuf",
        "//folly/lang:bits",
        "//folly/portability:windows",
        "@bzip2//:bz2",
        "@glog",
        "@lz4",
        "@lz4//:lz4_frame",
        "@lz4//:lz4_hc",
        "@snappy",
        "@xz//:lzma",
        "@zlib",
        "@zstd",
    ],
)

cpp_library(
    name = "compression_context_pool",
    hdrs = [
        "CompressionContextPool.h",
        "CompressionCoreLocalContextPool.h",
    ],
    deps = [
        "//folly:memory",
        "//folly:synchronized",
        "//folly/concurrency:cache_locality",
    ],
)

cpp_library(
    name = "compression_context_pool_singletons",
    srcs = ["CompressionContextPoolSingletons.cpp"],
    hdrs = ["CompressionContextPoolSingletons.h"],
    deps = [
        ":compression_context_pool",
        "//folly:portability",
        "//folly/memory:jemalloc_huge_page_allocator",
        "//folly/memory:malloc",
        "//folly/portability:config",
        "@zstd",
    ],
)

cpp_library(
    name = "quotient_multiset",
    srcs = [
        "QuotientMultiSet.cpp",
    ],
    hdrs = [
        "QuotientMultiSet.h",
        "QuotientMultiSet-inl.h",
    ],
    deps = [
        "//folly:format",
        "//folly:math",
        "//folly:portability",
        "//folly:range",
        "//folly/compression:instructions",
        "//folly/compression:select64",
        "//folly/io:iobuf",
        "//folly/lang:bits",
        "//folly/lang:bits_class",
        "//folly/lang:safe_assert",
        "@glog",
    ],
)

cpp_library(
    name = "instructions",
    hdrs = ["Instructions.h"],
    deps = [
        "//folly:cpu_id",
        "//folly:portability",
        "//folly/lang:assume",
        "//folly/portability:builtins",
        "@glog",
    ],
)

cpp_library(
    name = "select64",
    srcs = ["Select64.cpp"],
    hdrs = ["Select64.h"],
    deps = [
        ":instructions",
        "//folly:constexpr_math",
        "//folly:portability",
        "//folly:utility",
        "@glog",
    ],
)
